﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Alos.Common;
using Alos.Entity;
using Alos.IService;
using System.Threading.Tasks;

namespace Alos.LanClass.Api
{
    /// <summary>
    /// 学生座位顺序表
    /// </summary>
    public class SitPosSettingController : ApiController
    {
      ISitPosSettingService SitPosSettingService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_ISitPosSettingService"></param>
      public SitPosSettingController(ISitPosSettingService _ISitPosSettingService)
        {
            SitPosSettingService = _ISitPosSettingService;
        }
      /// <summary>
      /// 根据老师ID和班级ID获取学生座位顺序
      /// /// <param name="classsID">班级ID</param>
      /// </summary>
      [HttpGet]
      [Route("api/SitPosSetting/GetSitPosSetting")]
      public JsonRtn<SitPosSetting> GetSitPosSetting(int classsID)
      {
          var jsRtn = new JsonRtn<SitPosSetting>();
          jsRtn.data = SitPosSettingService.GetSitPosSetting((int)Common.Current.User.id, classsID);
          return jsRtn;
      }
      /// <summary>
      /// 根据老师ID和班级ID修改学生座位顺序
      /// </summary>
      /// <param name="SitPosSetting">座位信息表2</param>
      /// <returns></returns>
      [HttpPost]
      [Route("api/SitPosSetting/UpdateSitPosSetting")]
      public JsonRtn<dynamic> UpdateSitPosSetting([FromBody]SitPosSetting SitPosSetting)
      {
          var jsRtn = new JsonRtn<dynamic>();
              jsRtn.message=  SitPosSettingService.UpdateSitPosSetting(SitPosSetting.TeacherId, SitPosSetting.ClassId, SitPosSetting.ColNum, SitPosSetting.SequStduIds)?"座位调整成功":"座位调整失败";
          return jsRtn;
      }
    }
}
